//
//  UIImage+Color.m
//  Edu_iOS2018
//
//  Created by apple on 2018/1/4.
//  Copyright © 2018年 yanyan. All rights reserved.
//

#import "UIImage+Color.h"

@implementation UIImage (Color)

/*  根据颜色生成图片  */
+ (UIImage *)imageWithColor:(UIColor *)color size:(CGSize)size {
    if (!color || size.width <=0 || size.height <=0) return nil;
    CGRect rect = CGRectMake(0.0f, 0.0f, size.width, size.height);
    UIGraphicsBeginImageContextWithOptions(rect.size,NO, 0);
    CGContextRef context =UIGraphicsGetCurrentContext();
    CGContextSetFillColorWithColor(context, color.CGColor);
    CGContextFillRect(context, rect);
    
    UIImage *image =UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    return image;
}


@end
